<%--
  Created by IntelliJ IDEA.
  User: zjy
  Date: 2015/4/13
  Time: 16:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools"/>
<script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.js"></script>
<link rel="stylesheet" type="text/css" href="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.css"
      media="screen"/>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:1px;">
        <t:datagrid name="stuConsultantList" title="" actionUrl="consultantController.do?datagridFilter&studioId=${studioId}"
                    idField="consultantId" fit="true"
                    queryMode="group" onLoadSuccess="bandImg" checkbox="true">
            <t:dgCol title="consultantId" field="consultantId" hidden="true"></t:dgCol>
            <t:dgCol title="咨询师头像" field="aCustomerEntity.avatar" extendParams="formatter:avatarFormatter;"
                     align="center"></t:dgCol>
            <t:dgCol title="姓名" field="aCustomerEntity.realname" query="true"></t:dgCol>
            <t:dgCol title="性别" field="aCustomerEntity.sex" dictionary="sex"></t:dgCol>
            <t:dgCol title="手机号码" field="aCustomerEntity.phone" query="true"></t:dgCol>
            <t:dgCol title="生日" field="aCustomerEntity.birthday" formatter="yyyy-MM-dd" query="true"></t:dgCol>
            <t:dgCol title="省" field="aCustomerEntity.province"></t:dgCol>
            <t:dgCol title="市" field="aCustomerEntity.city"></t:dgCol>
            <t:dgCol title="区" field="aCustomerEntity.area"></t:dgCol>
            <t:dgCol title="入驻时间" field="createTime" formatter="yyyy-MM-dd" query="true"></t:dgCol>
            <t:dgCol title="最后登录" field="aCustomerEntity.lastLogintime" formatter="yyyy-MM-dd"></t:dgCol>
            <t:dgCol title="是否是专家" field="isExpert" dictionary="isno"></t:dgCol>
            <t:dgCol title="是否系统推荐" field="isRecomm" dictionary="isno"></t:dgCol>
            <t:dgCol title="排序" field="sort"></t:dgCol>
            <t:dgCol title="状态" field="isAuth" query="true" dictionary="newapply"></t:dgCol>
        </t:datagrid>
    </div>
</div>
<div style="display: none">
    <t:formvalid formid="formobj" layout="div" dialog="true"
                 action="consultantController.do?addConsultantToStudio&studioId=${studioId}" beforeSubmit="setUserIds">
        <input id="userIds" name="userIds" value="">
    </t:formvalid>
</div>
<script type="text/javascript">
    function setUserIds() {
        var consultantIds = getUserListSelections("consultantId");
        if (!consultantIds || consultantIds.length == 0) {
            tip('请选择咨询师');
            return;
        }
        $("#userIds").val(consultantIds);
        return true;
    }
    function getUserListSelections(field) {
        var ids = [];
        var rows = $('#stuConsultantList').datagrid('getSelections');
        for (var i = 0; i < rows.length; i++) {
            ids.push(rows[i][field]);
        }
        ids.join(',');
        return ids
    }
    function avatarFormatter(val, row) {
        return '<a rel="datagrid_group" href="' + val + '" title=""><img alt="" src="' + val + '" style="width:30px;height:30px;"></a>';
    }
    function bandImg() {
        $("a[rel=datagrid_group]").fancybox({
            'overlayShow': false,
            'transitionIn': 'elastic',
            'transitionOut': 'elastic'
        });
    }

    function f_update(title, url, id, width, height) {
        gridname = id;
        var rowsData = $('#' + id).datagrid('getSelections');
        if (!rowsData || rowsData.length == 0) {
            tip('请选择咨询师');
            return;
        }
    }

    //查看
    function previewView(title, url, id, width, height) {
        gridname = id;
        var rowsData = $('#' + id).datagrid('getSelections');
        if (!rowsData || rowsData.length == 0) {
            tip('请选择咨询师');
            return;
        }
        if (rowsData.length > 1) {
            tip('请选择一个咨询师');
            return;
        }
        url += '&consultantId=' + rowsData[0].consultantId;
        title = "咨询师预览";
        createdetailwindow(title, url, width, height);
    }

</script>

